package com.xingda.packing.dmds.events.lister;

import com.google.common.eventbus.Subscribe;
import com.xingda.packing.dmds.events.dto.*;
import com.xingda.packing.dmds.minitor.service.IPkActionService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 指令发送时保存指令执行信息
 *
 * @author LEGION
 */
@Component("actionDMDSLister")
public class ActionLister {

    @Resource
    IPkActionService pkActionService;

    @Subscribe
    public void save(EventActionScanCode actionScanCode) {
        pkActionService.addPkAction(actionScanCode);
    }

    /**
     * 抓取位放装箱位
     */
    @Subscribe
    public void save(EventActionPacking actionPacking) {
        pkActionService.addPkAction(actionPacking);
    }

    /**
     * 抓取位放缓存位
     */
    @Subscribe
    public void save(EventActionStorage actionStorage) {
        pkActionService.addPkAction(actionStorage);
    }

    /**
     * 从缓存位到装箱位
     */
    @Subscribe
    public void save(EventActionCachePacking actionCachePacking) {
        pkActionService.addPkAction(actionCachePacking);
    }

    @Subscribe
    public void update(EventActionType eventActionType) {
        pkActionService.finishPkAction(eventActionType);
    }

}
